//  不要给我WA WA 叫
//  一定AC
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>
#include <climits>
#define int long long 
using namespace std;
const int N = 1e5 + 10;
int a[N];
void solve()
{
    int n,pos;
    int b = 0;
    cin >> n >> pos;
    if(pos == 0)
    {
        cout << "0" << endl;
        return;
    }
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        if(pos > 0) 
        {
            pos = pos - x;
            b += abs(x);
        }
        else if(pos == 0)
        {
            cout << b << endl;
            return;
        }
        else 
        {
            pos += x;
            b += abs(x);
        }
    }
    cout << b << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t = 1;
    while(t -- )  solve();
    return 0;
}